package entity;

/**
 * 子弹类
 */
public class Bullet extends FlyingObject {
    private int speed; // 移动速度
    private boolean alive = true; // 是否存活
    
    public Bullet(int x, int y, java.awt.Image image, int speed) {
        this.x = x;
        this.y = y;
        this.image = image;
        this.width = image.getWidth(null);
        this.height = image.getHeight(null);
        this.speed = speed;
    }
    
    @Override
    public void move() {
        y += speed;
    }
    
    @Override
    public boolean isOutOfBounds(int panelWidth, int panelHeight) {
        return y < 0 || y > panelHeight;
    }
    
    @Override
    public boolean isAlive() {
        return alive;
    }
    
    public void setAlive(boolean alive) {
        this.alive = alive;
    }
    
    public int getSpeed() {
        return speed;
    }
    
    public void setSpeed(int speed) {
        this.speed = speed;
    }
}